package com.example.fashion.android.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;

import com.example.fashion.android.base.BaseActivity.BaseActivity;
import com.example.fashion.android.FourCompoents.activity.ActivityActivity;
import com.example.fashion.android.FourCompoents.activity.ProviderActivity;
import com.example.fashion.android.FourCompoents.activity.ReceiverActivity;
import com.example.fashion.android.FourCompoents.activity.ServiceActivity;
import com.example.fashion.android.globar.Constant;
import com.example.fashion.android.util.LayoutUtil;

/**
 * Android四大组件
 */
public class FourComponents extends BaseActivity implements  LayoutUtil.ClickCallBack {

    //界面布局
    LinearLayout mRootLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //创建一个线性布局
        mRootLayout = LayoutUtil.getLinearLayout(this,LinearLayout.VERTICAL, Gravity.CENTER);
        setContentView(mRootLayout);
    }

    /**
     * 初始化View
     */
    @Override
    public void initView() {
        //显示标题栏
        setSystemTitleName("四大组件");
    }


    /**
     * 初始化数据
     */
    @Override
    public void initData() {
        //添加功能列表
        LayoutUtil.addFunctionList(this, mRootLayout, Constant.FOUR_COMPONENT_RESOURCE_ID, this);
    }

    @Override
    protected void clear() {

    }

    /**
     * 功能列表的点击事件
     * @param tag
     */
    @Override
    public void onClickListener(int tag) {
        switch (tag){
            case 0:    //活动
                startActivity(new Intent(getApplicationContext(),ActivityActivity.class));
                break;
            case 1:    //服务
                startActivity(new Intent(getApplicationContext(),ServiceActivity.class));
                break;
            case 2:     //广播
                startActivity(new Intent(getApplicationContext(),ReceiverActivity.class));
                break;
            case 3:     //内容提供者
                startActivity(new Intent(getApplicationContext(),ProviderActivity.class));
                break;
            default:
                break;
        }
    }
}
